package com.example.user.controller;

import com.example.user.service.LoginService;
import com.example.user.service.UserServiceImpl;
import com.netflix.ribbon.proxy.annotation.Http;
import entity.LoginEntity;
import entity.Rsp;
import entity.UserEntity;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import util.JwtUtil;

/**
 * 用户登录
 */
@RestController
public class LoginController {

    @Autowired
    LoginService loginService;

    @Autowired
    UserServiceImpl userService;

    @PostMapping("/loginWithUsernameAndPass")
    public Rsp loginWithUsernameAndPass(@RequestBody LoginEntity loginParam) throws Exception {

        return loginService.loginWithUsernameAndPass(loginParam);

    }

    @GetMapping("/getUserInfo")
    public Rsp getUserInfo(@RequestHeader("userId") String userId){

        return Rsp.success(userService.getOneById(userId));
    }


    @PostMapping("/logout")
    public Rsp logout(@RequestHeader("userId") String userId){

        return Rsp.success("登出成功");
    }



}
